package com.zhangzhan.blog_service.service.impl;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhangzhan.base.constant.StatusCode;
import com.zhangzhan.base.common_model.result.ResponseResult;
import com.zhangzhan.base.utils.CopyBean;
import com.zhangzhan.blog_model.entity.Link;
import com.zhangzhan.blog_model.vos.GetAllLinkVo;
import com.zhangzhan.blog_service.mapper.LinkMapper;
import com.zhangzhan.blog_service.service.LinkService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 友链 服务实现类
 * </p>
 *
 * @author zhangzhan
 * @since 2024-02-01
 */
@Service
public class LinkServiceImpl extends ServiceImpl<LinkMapper, Link> implements LinkService {


    @Resource
    private LinkMapper linkMapper;

    /**
     * @return com.zhangzhan.blog_base.model.ResponseResult<java.util.List < com.zhangzhan.admin_model.vos.GetAllLinkVo>>
     * @description 友联查询
     * @author zhangyiheng
     * @date 2024/2/1 22:56
     */
    @Override
    public ResponseResult<List<GetAllLinkVo>> getAllLink() {
        //	在友链页面要查询出所有的审核通过的友链。

        List<Link> links = this.list(Wrappers.<Link>lambdaQuery()
                .eq(Link::getStatus, StatusCode.LINK_STATUS_NORMAL));


        return ResponseResult.okResult(CopyBean.copyBeanList(links,GetAllLinkVo.class));
    }
}
